//
//  TaskGuiJiStatusCell.m
//  LogisticsSupplier
//
//  Created by 吕晶 on 2021/4/8.
//  Copyright © 2021 吕晶. All rights reserved.
//

#import "TaskGuiJiStatusCell.h"

@interface TaskGuiJiStatusCell ()

@property (nonatomic, strong) UILabel *titleLab;
@property (nonatomic, strong) UILabel *timeLab;
@property (nonatomic, strong) UILabel *topLine;
@property (nonatomic, strong) UILabel *botLine;
@property (nonatomic, strong) UILabel *midDot;

@end

@implementation TaskGuiJiStatusCell

+ (instancetype)TaskGuiJiStatusCellWithTableView:(UITableView *)tableView {
    static NSString *cellID = @"TaskGuiJiStatusCell";
    TaskGuiJiStatusCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[TaskGuiJiStatusCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.backgroundColor = HexColor(0xffffff);
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        CGFloat viewW = ScreenW - 30;
        CGFloat lineH = 14;
        CGFloat lineW = 2;
        
        self.midDot = [UILabel new];
        self.midDot.nim_width = 14;
        self.midDot.nim_height = 14;
        self.midDot.nim_left = viewW * 0.4 - 14;
        self.midDot.nim_top = lineH;
        self.midDot.layer.masksToBounds = YES;
        self.midDot.layer.cornerRadius = 7;
        [self.contentView addSubview:self.midDot];
        
        self.topLine = [UILabel new];
        self.topLine.backgroundColor = HexColor(0xDBDCE6);
        self.topLine.nim_top = 0;
        self.topLine.nim_width = lineW;
        self.topLine.nim_centerX = self.midDot.nim_centerX;
        self.topLine.nim_height = lineH - 2;
        [self.contentView addSubview:self.topLine];
        
        self.botLine = [UILabel new];
        self.botLine.backgroundColor = HexColor(0xDBDCE6);
        self.botLine.nim_top = self.midDot.nim_bottom + 2;
        self.botLine.nim_width = lineW;
        self.botLine.nim_centerX = self.midDot.nim_centerX;
        self.botLine.nim_height = lineH - 2;
        [self addSubview:self.botLine];
        
        self.titleLab = [UILabel new];
        self.titleLab.nim_left = 10;
        self.titleLab.nim_height = 17;
        self.titleLab.nim_width = self.midDot.nim_left - 15 - self.titleLab.nim_left;
        self.titleLab.nim_centerY = self.midDot.nim_centerY;
        self.titleLab.textAlignment = NSTextAlignmentRight;
        self.titleLab.font = BoldFontOfSize(16);
        self.titleLab.textColor = HexColor(0x2B2C44);
        [self.contentView addSubview:self.titleLab];
        
        self.timeLab = [UILabel new];
        self.timeLab.nim_left = 15 + self.midDot.nim_right;
        self.timeLab.nim_height = 13;
        self.timeLab.nim_width = viewW - 10 - self.timeLab.nim_left;
        self.timeLab.nim_centerY = self.midDot.nim_centerY;
        self.timeLab.textAlignment = NSTextAlignmentLeft;
        self.timeLab.font = [UIFont systemFontOfSize:12];
        self.timeLab.textColor = HexColor(0x9C9DB3);
        [self.contentView addSubview:self.timeLab];
        
        self.height = self.botLine.nim_bottom;
    }
    return self;
}

-(void)setModel:(TaskGuiJiOrderStatusModel *)model {
    _model = model;
    [self configUI];
}

- (void)configUI {
    self.titleLab.text = self.model.value;
    self.timeLab.text = self.model.time;
    self.topLine.hidden = self.model.isFirst;
    self.botLine.hidden = self.model.isLast;
    self.midDot.backgroundColor = self.model.selected ? Color_ThemeColor : HexColor(0xCCCCD9);
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
